//
//  NSDate+YJWExtension.m
//  百思不得骑姐
//
//  Created by YJW on 16/12/5.
//  Copyright © 2016年 yijiang. All rights reserved.
//

#import "NSDate+YJWExtension.h"

@implementation NSDate (YJWExtension)

-(NSDateComponents *)deltaFrom:(NSDate *)from
{
    //创建日历
    NSCalendar *cal = [NSCalendar currentCalendar];
    //需要进行比较的元素
    NSCalendarUnit unit = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
    return [cal components:unit fromDate:from toDate:self options:0];
}

@end
